<!doctype html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">修改密码</h1>
			<a class="mui-action-back mui-icon mui-icon-back  mui-icon-backmui-pull-left"></a>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded" style="margin: 5px;">
				<h5>新密码：</h5>
				<div class="mui-input-row mui-password">
					<input id="newP" type="password" class="mui-input-password" maxlength="20">
				</div>
				<h5>确认密码：</h5>
				<div class="mui-input-row mui-password">
					<input id="enterP" type="password" class="mui-input-password" maxlength="20">
				</div>
				<form class="mui-input-group" style="margin-top: 10px;">
					<div class="mui-input-row">
						<label>验证码</label>
						<input id="sendCode" type="text" placeholder="输入您接受到的验证码" maxlength="20">
					</div>
				</form>
			</div>
			<div class="mui-col-sm-12 mui-col-xs-12">
				<button id="passwordSend" type="button" class="mui-btn mui-btn-primary mui-btn-block mui-btn-outlined">提交</button>
			</div>
		</div>
	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/myjs/localVarchar.js"></script>
	<script src="js/constatnt/var.js"></script>
	<script src="js/ipjs/ip.js"></script>
	<script type="text/javascript">
		mui.init()
		document.getElementById("enterP").addEventListener('blur', function() {
			if(document.getElementById("newP").value != document.getElementById("enterP").value) {
				mui.toast("两次输入密码不一致！");
				document.getElementById("enterP").value = "";
			}
		});
		document.getElementById("passwordSend").addEventListener('tap', function() {
			var code = document.getElementById("sendCode").value;
			var newP = document.getElementById("newP").value;
			var enterP = document.getElementById("enterP").value;

			var resetPassword = {
				code: code,
				newPassword: newP,
				phone: localStorage.getItem(LOCAL_USER_INFO)
			};
			if(resetPassword.code != "" && resetPassword.newPassword != "" && resetPassword.phone != "") {
				mui.ajax(ip + 'search/editPassword', {
					data: JSON.stringify(resetPassword),
					type: 'post',
					dataType: 'json',
					timeout: 10000,
					headers: {
						'Content-Type': 'application/json'
					},
					success: function(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						alert(data.data.object);
						if(data.data.code == OPERATION_SUCCESS) {
							$.openWindow({
								url: 'index-homePage.html',
								id: 'homePage'
							});
						} else if(data.data.code == OPERATION_FAIL) {
							mui.toast("密码修改失败！");
						}
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						mui.toast("系统异常！");
					}
				});
			} else {
				mui.toast("信息输入不完善");
			}

			if(newP == enterP) {

			} else {
				mui.toast("两次输入密码不一致！");
			}
		});
	</script>

</html>